package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.LocalMultiHopAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <Description> <br>
 *
 * @author cheng.leizhen01<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年3月16日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler <br>
 */
@Service
@AttrHandler(LocalMultiHopAttrHandler.class)
public class LocalMultiHopAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    /**
     * 用户设备Loopback地址	当省网转接与骨干网建立Multi-hop连接选择是，该字段显示，且为必填，否则隐藏
     * BGP Multi-hop跳数	当省网转接与骨干网建立Multi-hop连接选择是，该字段显示，且为必填，否则隐藏
     * BGP MD5认证码	       当省网转接与骨干网建立Multi-hop连接选择是，该字段显示，且为必填，否则隐藏
     */

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        if (Objects.isNull(attr) || KiteStringUtils.isEmpty(attr.getValue())) {
            return;
        }
        // 用户设备Loopback地址 200001568
        // BGP Multi-hop跳数 200001569
        // BGP MD5认证码 200001570
        if(KiteStringUtils.equalsAny(attr.getValue(),"1_0000106" )){
            LocalAttrHelper.showAndNotNull(inst, "200001568", "200001569", "200001570");
        } else {
            LocalAttrHelper.hideAndNullable(inst, "200001568", "200001569", "200001570");
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

}
